package com.example.library.studentfragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.library.R;

public class StudentHomeFragment extends Fragment {

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.student_home, container, false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        
        // 设置欢迎信息
        TextView welcomeText = view.findViewById(R.id.tv_welcome);
        // TODO: 从SharedPreferences或其他存储中获取用户名
        String username = "同学";
        welcomeText.setText("欢迎回来，" + username);

        // 设置信用分
        TextView creditScoreText = view.findViewById(R.id.tv_credit_score);
        // TODO: 从数据库获取信用分
        int creditScore = 100;
        creditScoreText.setText("信用分：" + creditScore);
    }
} 